﻿/*
 * 
 * User: Gavin Mead
 * Date: 11/24/2009
 * Time: 2:15 PM
 * 
 * 
 */

using System;
using NUnit.Framework;

using GraphLibrary;

namespace GraphLibraryTests
{
    [TestFixture]
    public class BaseEdgeIdTests
    {
        
        public class JunkEdgeId : IEdgeId
        {
            
            
            public IVertexId Vertex1Id {
                get {
                    throw new NotImplementedException();
                }
                set {
                    
                }
            }
            
            public IVertexId Vertex2Id {
                get {
                    throw new NotImplementedException();
                }
                set {
                    
                }
            }
            
            public string FriendlyName {
                get {
                    throw new NotImplementedException();
                }
                set {
                    throw new NotImplementedException();
                }
            }
        }
                
        [Test]
        [Description("Verfies that an IEdgeId returns true when performing " +
                     "an equals against itself")]
        public void EqualIEdgeIdsTest()
        {
            IVertexId id1 = new BaseVertexId();
            IVertexId id2 = new BaseVertexId();
            
            IEdgeId edgeId = new BaseEdgeId(id1, id2);
            
            Assert.True(edgeId.Equals(edgeId));
        }
        
        [Test]
        [Description("Verifies that an exception is thrown when either "  +
                     "if IVertexId1 or IVertexId2 are null")]
        public void NullIVertexIdsExceptionTest()
        {
            IVertexId id1 = null;
            IVertexId id2 = null;
            IVertexId id3 = new BaseVertexId();
            IVertexId id4 = new BaseVertexId();
            
            IEdgeId edgeId1 = null;
            IEdgeId edgeId2 = null;
            
            ArgumentNullException ex1 = Assert.Throws<ArgumentNullException>(delegate {
                                                                                edgeId1 = new BaseEdgeId(id1,
                                                                                                         id2);
                                                                            });
            
            ArgumentNullException ex2 = Assert.Throws<ArgumentNullException>(delegate {
                                                                                 edgeId2 = new BaseEdgeId(id1,
                                                                                                          id3);
                                                                             });
            ArgumentNullException ex3 = Assert.Throws<ArgumentNullException>(delegate {
                                                                                 edgeId1 = new BaseEdgeId(id3,
                                                                                                          id1);
                                                                                                       
                                                                             });
            
            Assert.NotNull(ex1);
            Assert.NotNull(ex2);
            Assert.NotNull(ex3);
        }
        
        [Test]
        [Description("Verifies that BaseEdgeId return false, when " +
                     "Equals() is called with a different IEdgeId " +
                     "implementation.")]
        public void JunkEdgeIdEqualityTest()
        {
            IEdgeId id1 = new BaseEdgeId(new BaseVertexId(), new BaseVertexId());
            Assert.False(id1.Equals(new JunkEdgeId()));
        }
    }
}
